<template>
  <div
    class="flex-h flex-vc date-item notice"
    @click="goToLink"
  >
    <img :src=item.LOGO>
    <div
      v-if="item.STATE===0"
      class="redCircle"
    ></div>
    <div class="flex-v message">
      <span class="flex1 title fontsize28">{{item.TITLE||formatDate}}</span>
      <span class="flex1 content fontsize22">{{item.CONTENT||formatDate}}</span>
    </div>
    <span class="user-tips fontsize24 time">{{item.CREATE_TIME||formatDate}}</span>
  </div>
</template>

<script>
import { go } from 'vue-xiaobu-utils'
import { messageRead } from '../api/api.js'
// import ScrollWithNet from '@/components/scroll/ScrollWithNet'
export default {
  components: {
    // 'scroll': ScrollWithNet
  },
  data() {
    return {
      formatDate: '-',
      noRead: false
    }
  },
  props: {
    // 传入获取列表数据的方法
    item: {
      type: String,
      default: null,
      required: true
    },
    key: {
      type: String,
      default: null,
      required: true
    },
    afreshState: {
      type: Function,
      default: null
    },
    getUnreadQuantity: {
      type: Function,
      default: null
    },
    appVersion: {
      type: String,
      default: null
    }
  },
  mounted() {

  },
  methods: {
    goToLink() { // 进入详情
      if (this.item.JUMP_URL) {
        if (this.item.JUMP_URL.indexOf('orderdetail') > -1 || this.item.JUMP_URL.indexOf('applyprogress') > -1) {
          if (this.item.JUMP_URL.indexOf('_ntv=false') === -1) {
            go(this.item.JUMP_URL + '&_ntv=false')
          } else {
            go(this.item.JUMP_URL)
          }
        } else {
          go(this.item.JUMP_URL)
        }
      } else {
        window.localStorage.setItem('iohnbfiubaskbibiud', JSON.stringify(this.item))
        // this.$router.push({ name: 'noticedetail' })
        this.goPage('city-app/noticedetail.html?_tv=true')
      }
      if (this.item.STATE === 0) {
        return messageRead(this.item.MESSAGE_ID)
          .then(res => {
            this.afreshState()
          })
          .catch(err => {
            console.dir(err)
          })
      }
    },
    // 跳转路由
    goPage(url) {
      console.log('跳转路由:' + url)
      this.$AppRouterUtils.open(url)
    }
  }
}
</script>

<style scoped>
.notice {
  margin-top: 0.2133rem;
  height: 2.1333rem;
  width: 10rem;
  background-color: #fff;
  position: relative;
  /* color: #999999; */
}
.redCircle {
  width: 0.32rem;
  height: 0.32rem;
  background-color: #e84d38;
  border-radius: 1rem;
  position: absolute;
  top: 0.1866rem;
  left: 1.7866rem;
}
.message {
  position: absolute;
  top: 0.32rem;
  left: 2.5733rem;
}
img {
  width: 1.6rem;
  height: 1.6rem;
  margin-left: 0.4rem;
  position: relative;
  border-radius: 0.1rem;
}
.title {
  /* font-size: 0.3733rem; */
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 4.0333rem;
  margin-bottom: 0.2133rem;
}
.content {
  color: #999999;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  width: 6.5333rem;
}
.time {
  position: absolute;
  right: 0.4rem;
  color: #cccccc;
  top: 0.4rem;
}
</style>
